package com.health.appoint.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.health.appoint.model.appoint.AddAppointRequest;
import com.health.appoint.model.appoint.GetAppointRequest;
import com.health.appoint.model.appoint.GetMyAppointRequest;
import com.health.appoint.model.appoint.TakeAppointRequest;
import com.health.appoint.model.vo.AppointVO;
import com.health.appoint.service.AppointService;
import com.health.common.common.BaseResponse;
import com.health.common.common.ResultUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhexueqi
 * @ClassName AppointController
 * @since 2024/8/17    19:26
 */
@RestController
@RequestMapping("/patient")
@Tag(name = "患者端预约管理")
public class PatientAppointController {

    @Resource
    private AppointService appointService;

    /**
     * 患者预约功能
     * @param appointRequest
     * @return
     */
    @PostMapping("/addAppoint")
    @Operation(summary = "患者预约")
    public BaseResponse<Boolean> addAppoint(@RequestBody @Valid AddAppointRequest appointRequest) throws Exception {
        Boolean res = appointService.addAppoint(appointRequest);
        return ResultUtils.success(res);
    }

    /**
     * 患者取号功能
     * @return
     */
    @PostMapping("/takeAppoint")
    @Operation(summary = "患者取号")
    public BaseResponse<Boolean> takeAppoint(@RequestBody @Valid TakeAppointRequest takeAppoint) throws Exception {
        Boolean res = appointService.takeAppoint(takeAppoint);
        return ResultUtils.success(res);
    }

    /**
     * 通过挂号ID获取挂号信息
     */
    @PostMapping("/getAppoint")
    @Operation(summary = "通过挂号ID获取挂号信息")
    public BaseResponse<AppointVO> getAppoint(@Valid GetAppointRequest getAppointRequest) throws Exception {
        AppointVO appointVO = appointService.getAppoint(getAppointRequest);
        return ResultUtils.success(appointVO);
    }

    /**
     * 查看自己的挂号信息
     */
    @PostMapping("/getMyAppoint")
    @Operation(summary = "查看自己的挂号信息")
    public BaseResponse<Page<AppointVO>> getMyAppoint(@RequestBody GetMyAppointRequest getMyAppointRequest) throws Exception {
        Page<AppointVO> appointVOList = appointService.getMyAppoint(getMyAppointRequest);
        return ResultUtils.success(appointVOList);
    }

}
